﻿using System;
using System.Web.UI;

using Model;
using Model.Components;

namespace FrameWork.web.Manager.Module.Tousu.Xin
{
    public partial class Exp : System.Web.UI.Page
    {
        Int32 IDX = (Int32)Common.sink("IDX", MethodType.Get, 10, 0, DataType.Int);
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                OnStart();
                Expword();
            }
        }

        private void OnStart()
        {
            T_TouSuEntity ut = BusinessFacadeModel.T_TouSuDisp(IDX);
            TID_Input.Text = TID_Disp.Text = ut.TID.ToString();
            ALaiyuan_Disp.Text = ut.ALaiyuan.ToString();
            AzhuanbanID_Disp.Text = ut.AzhuanbanID.ToString();
            AzhuanfangTime_Disp.Text = ut.AzhuanfangTime.ToString();
            ALiFangname_Disp.Text = ut.ALiFangname.ToString();
            ALaifangTime_Disp.Text = ut.ALaifangTime.ToString();
            AID_Disp.Text = ut.AID.ToString();
            APhone_Disp.Text = ut.APhone.ToString();
            AlaifangGroup_Disp.Text = ut.AlaifangGroup.ToString();
            Alaifangzhuzhi_Disp.Text = ut.Alaifangzhuzhi.ToString();
            Alaifangpostcode_Disp.Text = ut.Alaifangpostcode.ToString();
            Abeitousudanw_Disp.Text = ut.Abeitousudanw.ToString();
            AbeitousuName_Disp.Text = ut.AbeitousuName.ToString();
            Afanyingwenti_Disp.Text = ut.Afanyingwenti.ToString();
            AdiyiciTime_Disp.Text = ut.AdiyiciTime.ToString();
            Asunshi_Disp.Text = ut.Asunshi.ToString();
            Azhinengbumen_Disp.Text = ut.Azhinengbumen.ToString();
            ATimeAndGroup_Disp.Text = ut.ATimeAndGroup.ToString();
            AfanyingTime_Disp.Text = ut.AfanyingTime.ToString();
            Achuliqingkuang_Disp.Text = ut.Achuliqingkuang.ToString();
            ADafu_Disp.Text = ut.ADafu.ToString();
            AShenqingfucha_Disp.Text = ut.AShenqingfucha.ToString();
            AfuchaTime_Disp.Text = ut.AfuchaTime.ToString();
            AShiyijian_Disp.Text = ut.AShiyijian.ToString();
            Axinfangbanyijian_Disp.Text = ut.Axinfangbanyijian.ToString();
            AlingdaoYijian_Disp.Text = ut.AlingdaoYijian.ToString();
            Azhuanchu_Disp.Text = ut.Azhuanchu.ToString();
            AzhuanchuTime_Disp.Text = ut.AzhuanchuTime.ToString();
            AyaoqiuTime_Disp.Text = ut.AyaoqiuTime.ToString();
            Ajieguo_Disp.Text = ut.Ajieguo.ToString();
            Ajiluren_Disp.Text = ut.Ajiluren.ToString();
            AjilushiTime_Disp.Text = ut.AjilushiTime.ToString();
        }

        private void Expword()
        {
            System.IO.StringWriter SW = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter HTW = new System.Web.UI.HtmlTextWriter(SW);
            Page.RenderControl(HTW);
            //Page为要导出的对象,当前是Page,如果是DataGrid,DataList等都可以
            Response.Buffer = true;
            Response.Clear();
            Response.ClearContent();
            Response.ClearHeaders();
            Response.ContentType = "Response.ContentType";
            //Response.ContentType是输出流的 HTTP MIME 类型
            //Response.ContentType      --- word文件
            //application/vnd.ms-excel --- excel文件
            //
            Response.Charset = "utf-8";
            Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");
            Response.AddHeader("Content-Disposition", "attachment;filename=XXX.doc");
            //attachment --- 作为附件下载
            //inline --- 在线打开
            //filename如过是中文,则可以用HttpUtility.UrlEncode(fileName,System.Text.Encoding.UTF8)
            //进行进行编码,以解决文件名乱码的问题
            Response.Write(SW.ToString());
            Response.Flush();
            Response.Close();
        }
    }
}